/*tooltip.js*/
var OP = (navigator.userAgent.indexOf('Opera') != -1);
var IE = (navigator.userAgent.indexOf('MSIE') != -1 && !OP);
var GK = (navigator.userAgent.indexOf('Gecko') != -1);
var SA = (navigator.userAgent.indexOf('Safari') != -1);
var DOM = document.getElementById;

var tooltip = null;

function TOOLTIP() {
//----------------------------------------------------------------------------------------------------
// Configuration
//----------------------------------------------------------------------------------------------------
  this.width = 150;                     // width (pixels)
  this.bgColor = "#1f3255";             // background color
  this.textFont = "Arial";      // text font family
  this.textSize = 12;                   // text font size (pixels)
  this.textColor = "#FFFFFF";           // text color
  this.border = "1px solid #0c1b38";   // border (CSS spec: size style color, e.g. "1px solid #D00000")
  this.opacity = 80;                    // opacity (0 - 100); not supported by all browsers
  this.cursorDistance = 10;              // distance from mouse cursor (pixels)

  // don't change
  this.text = '';
  this.height = 0;
  this.obj = null;
  this.active = false;

//----------------------------------------------------------------------------------------------------
// Methods
//----------------------------------------------------------------------------------------------------
  this.create = function() {
    if(!this.obj) this.init();

    var s = (this.textFont ? 'font-family:' + this.textFont + '; ' : '') +
            (this.textSize ? 'font-size:' + this.textSize + 'px; ' : '') +
            (this.border ? 'border:' + this.border + '; ' : '') +
            ('padding:4px 4px; ') +
            (this.textColor ? 'color:' + this.textColor + '; ' : '');

    var t = '<table border=0 cellspacing=0 cellpadding=4 width=' + this.width + '><tr>' +
            '<td align=center' + (s ? ' style="' + s + '"' : '') + '>' + this.text +
            '</td></tr></table>';

    if(DOM || IE) this.obj.innerHTML = t;
    if(DOM) this.height = this.obj.offsetHeight;
    else if(IE) this.height = this.obj.style.pixelHeight;
    if(this.bgColor) this.obj.style.backgroundColor = this.bgColor;

    this.setOpacity();
    this.move();
    this.show();
  }

  this.init = function() {
    if(DOM) this.obj = document.getElementById('ToolTip');
    else if(IE) this.obj = document.all.ToolTip;
  }

  this.move = function() {
    var winX = getWinX() - (((GK && !SA) || OP) ? 17 : 0);
    var winY = getWinY() - (((GK && !SA) || OP) ? 17 : 0);
    var x = mouseX;
    var y = mouseY;

    if(x + this.width + this.cursorDistance > winX + getScrX())
      x -= this.width + this.cursorDistance;
    else x += this.cursorDistance;

    if(y + this.height + this.cursorDistance > winY + getScrY())
      y -= this.height;
    else y += this.cursorDistance;

    this.obj.style.left = x + 'px';
    this.obj.style.top = y + 'px';
  }

  this.show = function() {
    this.obj.style.zIndex = 69;
    this.active = true;
    this.obj.style.visibility = 'visible';
  }

  this.hide = function() {
    this.obj.style.zIndex = -1;
    this.active = false;
    this.obj.style.visibility = 'hidden';
  }

  this.setOpacity = function() {
    this.obj.style.opacity = this.opacity / 100;
    this.obj.style.MozOpacity = this.opacity / 100;
    this.obj.style.KhtmlOpacity = this.opacity / 100;
    this.obj.style.filter = 'alpha(opacity=' + this.opacity + ')';
  }
}

//----------------------------------------------------------------------------------------------------
// Global functions
//----------------------------------------------------------------------------------------------------
function getScrX() {
  var offset = 0;
  if(window.pageXOffset)
    offset = window.pageXOffset;
  else if(document.documentElement && document.documentElement.scrollLeft)
    offset = document.documentElement.scrollLeft;
  else if(document.body && document.body.scrollLeft)
    offset = document.body.scrollLeft;
  return offset;
}

function getScrY() {
  var offset = 0;
  if(window.pageYOffset)
    offset = window.pageYOffset;
  else if(document.documentElement && document.documentElement.scrollTop)
    offset = document.documentElement.scrollTop;
  else if(document.body && document.body.scrollTop)
    offset = document.body.scrollTop;
  return offset;
}

function getWinX() {
  var size = 0;
  if(window.innerWidth)
    size = window.innerWidth;
  else if(document.documentElement && document.documentElement.clientWidth)
    size = document.documentElement.clientWidth;
  else if(document.body && document.body.clientWidth)
    size = document.body.clientWidth;
  else size = screen.width;
  return size;
}

function getWinY() {
  var size = 0;
  if(window.innerHeight)
    size = window.innerHeight;
  else if(document.documentElement && document.documentElement.clientHeight)
    size = document.documentElement.clientHeight;
  else if(document.body && document.body.clientHeight)
    size = document.body.clientHeight;
  else size = screen.height;
  return size;
}

function getMouseXY(e) {
  if(e && e.pageX != null) {
    mouseX = e.pageX;
    mouseY = e.pageY;
  }
  else if(event && event.clientX != null) {
    mouseX = event.clientX + getScrX();
    mouseY = event.clientY + getScrY();
  }
  if(mouseX < 0) mouseX = 0;
  if(mouseY < 0) mouseY = 0;
  if(tooltip && tooltip.active) tooltip.move();
}

function toolTip(text, width, opacity) {
  if(text) {
    tooltip = new TOOLTIP();
    tooltip.text = text;
    if(width) tooltip.width = width;
    if(opacity) tooltip.opacity = opacity;
    tooltip.create();
  }
  else if(tooltip) tooltip.hide();
}

//----------------------------------------------------------------------------------------------------
// Build tooltip box
//----------------------------------------------------------------------------------------------------
document.write('<div id="ToolTip" style="position:absolute; visibility:hidden"></div>');

//----------------------------------------------------------------------------------------------------
// Event handlers
//----------------------------------------------------------------------------------------------------
var mouseX = mouseY = 0;
document.onmousemove = getMouseXY;
//----------------------------------------------------------------------------------------------------
/*pfl.js*/
var aPflinks = new Array(51);
aPflinks[0] = new Object;
aPflinks[0].sLink = "http://www.advansys.com/www.recycling-services.co.uk";
aPflinks[0].sID= "167";
aPflinks[1] = new Object;
aPflinks[1].sLink = "";
aPflinks[1].sID= "142";
aPflinks[2] = new Object;
aPflinks[2].sLink = "";
aPflinks[2].sID= "139";
aPflinks[3] = new Object;
aPflinks[3].sLink = "";
aPflinks[3].sID= "140";
aPflinks[4] = new Object;
aPflinks[4].sLink = "www.stores.ebay.co.uk/tptoysdirect";
aPflinks[4].sID= "166";
aPflinks[5] = new Object;
aPflinks[5].sLink = "http://www.advansys.com/www.yakult.co.uk";
aPflinks[5].sID= "74";
aPflinks[6] = new Object;
aPflinks[6].sLink = "http://www.advansys.com/www.tie-rack.co.uk";
aPflinks[6].sID= "132";
aPflinks[7] = new Object;
aPflinks[7].sLink = "";
aPflinks[7].sID= "136";
aPflinks[8] = new Object;
aPflinks[8].sLink = "http://www.advansys.com/www.climatecoolingltd.co.uk";
aPflinks[8].sID= "143";
aPflinks[9] = new Object;
aPflinks[9].sLink = "";
aPflinks[9].sID= "128";
aPflinks[10] = new Object;
aPflinks[10].sLink = "http://www.advansys.com/www.lucozadeshop.com";
aPflinks[10].sID= "110";
aPflinks[11] = new Object;
aPflinks[11].sLink = "http://www.advansys.com/www.flavourbarevents.com";
aPflinks[11].sID= "84";
aPflinks[12] = new Object;
aPflinks[12].sLink = "http://www.advansys.com/www.gskdirect.co.uk";
aPflinks[12].sID= "135";
aPflinks[13] = new Object;
aPflinks[13].sLink = "http://www.advansys.com/www.spottypottery.co.uk";
aPflinks[13].sID= "120";
aPflinks[14] = new Object;
aPflinks[14].sLink = "http://www.advansys.com/www.attitudeinc.co.uk";
aPflinks[14].sID= "137";
aPflinks[15] = new Object;
aPflinks[15].sLink = "http://www.advansys.com/www.twostore.co.uk";
aPflinks[15].sID= "134";
aPflinks[16] = new Object;
aPflinks[16].sLink = "http://www.advansys.com/www.orion-waste.co.uk";
aPflinks[16].sID= "108";
aPflinks[17] = new Object;
aPflinks[17].sLink = "http://www.advansys.com/www.orion-citywaste.co.uk";
aPflinks[17].sID= "130";
aPflinks[18] = new Object;
aPflinks[18].sLink = "http://www.advansys.com/www.nflcashdirect.co.uk";
aPflinks[18].sID= "131";
aPflinks[19] = new Object;
aPflinks[19].sLink = "http://www.advansys.com/www.loveyourjunk.co.uk";
aPflinks[19].sID= "127";
aPflinks[20] = new Object;
aPflinks[20].sLink = "http://www.advansys.com/www.sinkstapsandbeyond.com";
aPflinks[20].sID= "107";
aPflinks[21] = new Object;
aPflinks[21].sLink = "http://www.advansys.com/www.partyshowroom.co.uk";
aPflinks[21].sID= "133";
aPflinks[22] = new Object;
aPflinks[22].sLink = "http://www.advansys.com/www.healthandsafetytest.co.uk";
aPflinks[22].sID= "122";
aPflinks[23] = new Object;
aPflinks[23].sLink = "http://www.advansys.com/dttstore.prometric.com";
aPflinks[23].sID= "121";
aPflinks[24] = new Object;
aPflinks[24].sLink = "http://www.advansys.com/www.serendipitydiamonds.co.uk";
aPflinks[24].sID= "33";
aPflinks[25] = new Object;
aPflinks[25].sLink = "http://www.advansys.com/www.helenslittleangels.co.uk";
aPflinks[25].sID= "117";
aPflinks[26] = new Object;
aPflinks[26].sLink = "http://www.advansys.com/www.weighttogo.com";
aPflinks[26].sID= "126";
aPflinks[27] = new Object;
aPflinks[27].sLink = "http://www.advansys.com/www.hawkinsandscott.co.uk";
aPflinks[27].sID= "115";
aPflinks[28] = new Object;
aPflinks[28].sLink = "http://www.advansys.com/www.barloworldstore.co.uk";
aPflinks[28].sID= "114";
aPflinks[29] = new Object;
aPflinks[29].sLink = "http://www.advansys.com/www.petersroofing.co.uk";
aPflinks[29].sID= "26";
aPflinks[30] = new Object;
aPflinks[30].sLink = "http://www.advansys.com/www.kidsiqbooks.com";
aPflinks[30].sID= "123";
aPflinks[31] = new Object;
aPflinks[31].sLink = "http://www.advansys.com/www.nordickids.co.uk";
aPflinks[31].sID= "119";
aPflinks[32] = new Object;
aPflinks[32].sLink = "http://www.advansys.com/www.classiccarsglobal.com";
aPflinks[32].sID= "88";
aPflinks[33] = new Object;
aPflinks[33].sLink = "http://www.advansys.com/www.ppcjunkies.co.uk";
aPflinks[33].sID= "86";
aPflinks[34] = new Object;
aPflinks[34].sLink = "http://www.advansys.com/www.smsjunkies.co.uk";
aPflinks[34].sID= "80";
aPflinks[35] = new Object;
aPflinks[35].sLink = "";
aPflinks[35].sID= "44";
aPflinks[36] = new Object;
aPflinks[36].sLink = "http://www.advansys.com/www.minigiants.com";
aPflinks[36].sID= "124";
aPflinks[37] = new Object;
aPflinks[37].sLink = "http://www.advansys.com/www.firstlightcosmetics.com";
aPflinks[37].sID= "129";
aPflinks[38] = new Object;
aPflinks[38].sLink = "http://www.advansys.com/www.barefacedbeauty.co.uk";
aPflinks[38].sID= "45";
aPflinks[39] = new Object;
aPflinks[39].sLink = "http://www.advansys.com/www.emailjunkies.co.uk";
aPflinks[39].sID= "79";
aPflinks[40] = new Object;
aPflinks[40].sLink = "http://www.advansys.com/www.scentsationalperfumes.com";
aPflinks[40].sID= "125";
aPflinks[41] = new Object;
aPflinks[41].sLink = "http://www.advansys.com/www.prskconsulting.co.uk";
aPflinks[41].sID= "76";
aPflinks[42] = new Object;
aPflinks[42].sLink = "http://www.advansys.com/www.withlove.com";
aPflinks[42].sID= "38";
aPflinks[43] = new Object;
aPflinks[43].sLink = "http://www.advansys.com/www.aspirediamonds.co.uk";
aPflinks[43].sID= "118";
aPflinks[44] = new Object;
aPflinks[44].sLink = "http://www.advansys.com/www.rax2go.com";
aPflinks[44].sID= "65";
aPflinks[45] = new Object;
aPflinks[45].sLink = "http://www.advansys.com/www.speckledfrogtoys.co.uk";
aPflinks[45].sID= "73";
aPflinks[46] = new Object;
aPflinks[46].sLink = "http://www.advansys.com/www.wi5.com";
aPflinks[46].sID= "43";
aPflinks[47] = new Object;
aPflinks[47].sLink = "http://www.advansys.com/www.skiphireuk.co.uk";
aPflinks[47].sID= "34";
aPflinks[48] = new Object;
aPflinks[48].sLink = "http://www.advansys.com/www.homexchangevacation.com";
aPflinks[48].sID= "55";
aPflinks[49] = new Object;
aPflinks[49].sLink = "http://www.advansys.com/www.callingnow.co.uk";
aPflinks[49].sID= "116";
aPflinks[50] = new Object;
aPflinks[50].sLink = "http://www.advansys.com/www.petaldolls.com";
aPflinks[50].sID= "40";
/*misc.js*/
function change_to(xValue) {
  if (xValue != 0) {
	location.href = xValue;
  }
}

$(document).ready(function(){
	$(".must_be_phone_number").keydown(function(event) {
        switch(event.keyCode)
        {
            case 8:
            case 9:
            case 32:
            case 107:
            case 109:
            case 48:
            case 49:
            case 50:
            case 51:
            case 52:
            case 53:
            case 54:
            case 55:
            case 56:
            case 57:
            
            case 96:
            case 97:
            case 98:
            case 99:
            case 100:
            case 101:
            case 102:
            case 103:
            case 104:
            case 105:
            {
                if ((true == event.shiftKey) && (107 != event.keyCode))
                {
                    event.preventDefault();
                }
                /* console.log('Shift: ' + event.shiftKey + ' Key: ' + event.keyCode + ' Char: ' + String.fromCharCode(event.keyCode)); */
            }
            break;
            default:
               //console.log('Shift: ' + event.shiftKey + ' Key: ' + event.keyCode + ' Char: ' + String.fromCharCode(event.keyCode)); 
                if ((false == event.ctrlKey) || ((true == event.ctrlKey) && ((65 != event.keyCode) && (67 != event.keyCode) && (86 != event.keyCode))))
                {
                    event.preventDefault();
                }                    
        }  
	});
	
	$('.tab').click(function () {
		$('.tab').removeClass('act');
		$('.tab').parent().find('.tabst').removeClass('actcornerst');
		$('.tab').parent().find('.taben').removeClass('actcorneren');
		$(this).addClass('act');
		$(this).prev().addClass('actcornerst');
		$(this).next().addClass('actcorneren');
		$('.why2').hide();
		$('.why2').eq($('.tab').index(this)).show();
	});
	
	$('.tab').mouseover(function(){
		$(this).prev().addClass('actcornerst');
		$(this).next().addClass('actcorneren');
	});
	
	$('.tab').mouseout(function(){
		if (!$(this).is('.act')) {
			$(this).prev().removeClass('actcornerst');
			$(this).next().removeClass('actcorneren');
		}
	});
	
	$('.read_more').click(function () {
		$(this).next().slideToggle();
		$(this).hide("fast");
		$(this).next().next().slideToggle();
	});
	
	$('.read_less').click(function () {
		var temp = null; 
		temp = $(this).prev().prev();
		$(this).slideToggle();
		$(temp).next().slideToggle();
		$(temp).show("fast");
	});


	if (document.getElementById("bottBtm")){
		$("div#bottBtm a").click( function () {
			if ($(this).text() == 'read more �') {
				$(this).text('� less');
				$(this).attr('title','� less');
				$('div.bottHidden').slideToggle('normal');
			} else {
				$(this).text('read more �');
				$(this).attr('title','read more �');
				$('div.bottHidden').slideToggle('normal');
			}
			return false;
		});
	}
	equalHeight($(".cntclmn"));

	var slideShow = $('.slideShow').slideShow({
		interval: 6
	});
	// now add logic to play/pause button
	$('.slideShow a.togglePlayback').click(function() {
		if (slideShow.isPlaying()) {
			$(this).css('backgroundPosition', '-44px -34px');
		} else {
			$(this).css('backgroundPosition', '-25px -34px');
		}
		slideShow.togglePlayback();
	});

    $(function() {
		if (document.getElementById("corpidenttbl")){
			$('#corpidenttbl a').lightBox();
		}
    });
	if (document.getElementById("clientslide")){
		$('#clientslide').cycle({
			fx: 'fade'
		});
	}
	
	//CONTENT STUFF
	$('.pdfbtn').hover(
	function () {
		$(this).attr("src","img.ashx-i=-images-design-multichannelpdf.gif"/*tpa=http://www.advansys.com/img.ashx?i=/images/design/multichannelpdf.gif*/); 
	}, 
	function () {
		$(this).attr("src","img.ashx-i=-images-design-multichannelpdfactv.gif"/*tpa=http://www.advansys.com/img.ashx?i=/images/design/multichannelpdfactv.gif*/); 
	}
	);

	if (document.getElementById("qckcallback")){

		$("#qckcallback .qckname").click( function () {
			if ($(this).val() == 'name*') {
				$(this).val('');
			}
			return false;
		});
		$("#qckcallback .qckemail").click( function () {
			if ($(this).val() == 'email*') {
				$(this).val('');
			}
			return false;
		});
		$("#qckcallback .qckphone").click( function () {
			if ($(this).val() == 'phone*') {
				$(this).val('');
			}
			return false;
		});
		$("#qckcallback .qckenquiry").click( function () {
			if ($(this).val() == 'message') {
				$(this).val('');
			}
			return false;
		});
		$("#qckcallback .qckcaptcha").click( function () {
			if ($(this).val() == 'enter code*') {
				$(this).val('');
			}
			return false;
		});
	}
	
	
	var ojectas = document.getElementById("PortfolioCategoryID");
		if (ojectas != null) {
		filterportfolios(ojectas);
		filterportfoliostrio(ojectas);
		}
	
});

function sdopen(img, id) {
    var DomainURL = 'http://otosaithanh.com/FrontEnd/';
	var tmpel =  document.getElementById(id);
	if (tmpel.style.display=="none" || tmpel.style.display == ""){
	    img.src = DomainURL + "images/Tooltip/icon_arrowex.png"/*tpa=http://www.advansys.com/img.ashx?i=/images/design/sidebarminus.gif*/
		$("#"+id).animate({height: "toggle"}, 500);
	}else{
    img.src = DomainURL + "images/Tooltip/icon_arrowco.png"/*tpa=http://www.advansys.com/img.ashx?i=/images/design/sidebarplus.gif*/
		$("#"+id).animate({height: "toggle"}, 500)			
	}
}
	
function equalHeight(group) {
   tallest = 0;
   group.each(function() {
      thisHeight = $(this).height();
      if(thisHeight > tallest) {
         tallest = thisHeight;
      }
   });
   group.height(tallest);
}


function openpfl (id){
for (i=0;i<aPflinks.length;i++){
	if (aPflinks[i].sID == id){
	window.open('http://'+aPflinks[i].sLink,'_blank')
	}
} 
}

function clrenquiry(txt){
	if (txt.innerHTML == "e.g. ecommerce solution"){
		txt.innerHTML = ""
	}
}


function ValidateCallbackPort(form){
	var vCheck = true;

	if(form.name.value=='') {
		ContactBlinkBlink(form.name);
		vCheck = false;
	} else {

	}
	
	if(form.phone.value=='') {
		ContactBlinkBlink(form.phone);
		vCheck = false;
	} else {

	}
	
	if(form.email.value=='' || !CheckEmail(form.email.value)) {
		ContactBlinkBlink(form.email);
		vCheck = false;
	} else {

	}
	
	if(form.captcha.value=='') {
		ContactBlinkBlink(form.captcha);
		vCheck = false;
	} else {

	}
	
	if (!vCheck)  {
		return false;
	}
}

function ValidateCallback(form){
/*if (form.name.value=='') {alert('Please fill in your name'); form.name.focus(); return false}
if (form.phone.value=='') {alert('Please fill in your contact telephone number'); form.phone.focus(); return false}
if (form.email.value=='') {alert('Please fill in your email address'); form.email.focus(); return false}
if (!CheckEmail(form.email.value)) {alert('Invalid email address'); form.email.focus(); return false}
if (form.enquiry.value=='') {alert('Please enter enquiry details'); form.enquiry.focus(); return false}
if (form.captcha.value=='') {alert('Please enter the security code'); form.captcha.focus(); return false}*/

	var vCheck = true;
	if(form.name.value=='' || form.name.value=='name*') {
		$(form.name).parent().addClass("hdcallbackinput1_err");
		vCheck = false;
	} else {
		$(form.name).parent().removeClass("hdcallbackinput1_err");
	}
	
	if(form.email.value=='' || form.email.value=='email*') {
		$(form.email).parent().addClass("hdcallbackinput1_err");
		vCheck = false;
	} else {
		$(form.email).parent().removeClass("hdcallbackinput1_err");
	}
	
	if(!CheckEmail(form.email.value)) {
		$(form.email).parent().addClass("hdcallbackinput1_err");
		vCheck = false;
	} else {
		$(form.email).parent().removeClass("hdcallbackinput1_err");
	}
	
	if(form.phone.value=='' || form.phone.value=='phone*') {
		$(form.phone).parent().addClass("hdcallbackinput1_err");
		vCheck = false;
	} else {
		$(form.phone).parent().removeClass("hdcallbackinput1_err");
	}
	
	if(form.enquiry.value=='' || form.enquiry.value=='message') {
		$(form.enquiry).parent().addClass("hdcallbackarea_err");
		vCheck = false;
	} else {
		$(form.enquiry).parent().removeClass("hdcallbackarea_err");
	}
	
	if(form.phone.value=='' || form.phone.value=='phone*') {
		$(form.phone).parent().addClass("hdcallbackinput1_err");
		vCheck = false;
	} else {
		$(form.phone).parent().removeClass("hdcallbackinput1_err");
	}
	
	if(form.captcha.value=='' || form.captcha.value=='enter code*' || form.captcha.value.length !=6) {
		$(form.captcha).parent().addClass("hdcallbackcp_err");
		vCheck = false;
	} else {
		$(form.captcha).parent().removeClass("hdcallbackcp_err");
	}
	
	if (!vCheck)  {
		return false;
	}
}

function BlinkBlinkAnimation(pInput, pClass){
	$(pInput).parent().prepend("<div class='" + pClass + "'></div>");
	$(pInput).parent().find("." + pClass).css({opacity: .0});
	$(pInput).parent().find("." + pClass).animate({opacity: .5}, 800);
	$(pInput).parent().find("." + pClass).animate({opacity: .0}, 800);
	$(pInput).parent().find("." + pClass).animate({opacity: .5}, 800);
	$(pInput).parent().find("." + pClass).animate({opacity: .0}, 800, function(){$(pInput).parent().find("." + pClass).remove()});
}

function ValidateQuickCallback(form){
	var vCheck = true;
	$('.hdcallbackinput1_err').remove();
	$('.hdcallbackcp_err').remove();
	
	if(form.name.value=='' || form.name.value=='name*') {
		BlinkBlinkAnimation('input[name="name"]', 'hdcallbackinput1_err');
		vCheck = false;
	} else {
		$(form.name).parent().removeClass("hdcallbackinput1_err");
	}
	
	if(form.email.value=='' || form.email.value=='email*') {
		BlinkBlinkAnimation('input[name="email"]', 'hdcallbackinput1_err');
		vCheck = false;
	} else {
		$(form.email).parent().removeClass("hdcallbackinput1_err");
	}
	
	if(!CheckEmail(form.email.value)) {
		BlinkBlinkAnimation('input[name="email"]', 'hdcallbackinput1_err');
		vCheck = false;
	} else {
		$(form.email).parent().removeClass("hdcallbackinput1_err");
	}
	
	if(form.phone.value=='' || form.phone.value=='phone*') {
		BlinkBlinkAnimation('input[name="phone"]', 'hdcallbackinput1_err');
		vCheck = false;
	} else {
		$(form.phone).parent().removeClass("hdcallbackinput1_err");
	}
	
	/*if(form.enquiry.value=='' || form.enquiry.value=='message') {
		$(form.enquiry).parent().addClass("hdcallbackarea_err");
		vCheck = false;
	} else {
		$(form.enquiry).parent().removeClass("hdcallbackarea_err");
	}*/
	
	if(form.captcha.value=='' || form.captcha.value=='enter code*' || form.captcha.value.length !=6) {
		BlinkBlinkAnimation('input[name="captcha"]', 'hdcallbackcp_err');
		vCheck = false;
	} else {
		$(form.captcha).parent().removeClass("hdcallbackcp_err");
	}
	
	if (!vCheck)  {
		return false;
	}
}

function ContactBlinkBlink(pInput) {
	var vColor1 = '#ffdede';
	var vColor2 = '#ffffff';
	var vBColor1 = '1px solid #E50F0F';
	var vBColor2 = '1px solid #BDBDBD';
	var vInterval = 500;

	$(pInput).css("background-color", vColor1);
	$(pInput).css("border", vBColor1);
	
	$(pInput).animate({opacity: .4}, vInterval);
	$(pInput).animate({opacity: 1.0}, vInterval);
	$(pInput).animate({opacity: .4}, vInterval);
	$(pInput).animate({opacity: 1.0}, vInterval, function(){$(pInput).css("background-color", vColor2); $(pInput).css("border", vBColor2);});
}

function ValidateContact(form){
	var vCheck = true;
	if(form.name.value=='') {
		ContactBlinkBlink(form.name);
		vCheck = false;
	} else {

	}
	
	if(form.companyname.value=='') {
		ContactBlinkBlink(form.companyname);
		vCheck = false;
	} else {

	}
	
	if(form.email.value=='' || !CheckEmail(form.email.value)) {
		ContactBlinkBlink(form.email);
		vCheck = false;
	} else {

	}
	
	if(form.telephone.value=='') {
		ContactBlinkBlink(form.telephone);
		vCheck = false;
	} else {

	}
	
	if((form.captcha.value=='') || (form.captcha.value.length !=6)) {
		ContactBlinkBlink(form.captcha);
		vCheck = false;
	} else {

	}
	
	if (!vCheck)  {
		return false;
	}
}

function articefrml(form){
if (form.firstname.value=='') {alert('Please fill in your first name'); form.firstname.focus(); return false}
if (form.lastname.value=='') {alert('Please fill in your last name'); form.lastname.focus(); return false}
if (form.email.value=='') {alert('Please fill in your email address'); form.email.focus(); return false}
if (!CheckEmail(form.email.value)) {alert('Invalid email address'); form.email.focus(); return false}
}

function CheckEmail(address) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(address)){
		return (true)
	}
		return (false)
}

function submitsearch(){
	document.fsearch.action='/search/'+document.getElementById('search').value;
	document.fsearch.submit();
}

function searchOnSubmit(frm){
	var tmpstr = document.getElementById('search').value;
	tmpstr = tmpstr.replace(" ","_");
	frm.action = '/search/'+tmpstr;
}
/*ajax.js*/
			var DivId;
			var status = true;
			var time = 0;
			var DepIDbefore = 0;
			var TabIDbefore = 1;
			var FirstGo = true;
			//var objektai = new Array();
			
			var tmpDivIds = new Array();
			
			function XmlHttp( ){
                this.CreateXmlHttpObject = CreateXmlHttpObject;
                this.GetUrlContent              = GetUrlContent;
                this.GetResponseText          = GetResponseText;
                this.GetReadyState              = GetReadyState;           
                this.HttpMethod = 'POST'; // default
                this.objXmlHttp = this.CreateXmlHttpObject();
            }

            // Initialize XMLHttpObject
            function CreateXmlHttpObject(){
                var xmlhttp=false;
                try {
                    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
                } catch (e) {
                try {
                    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (E) {
                    xmlhttp = false;
                }
            }
       

            if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest();
            }
                return xmlhttp;
            }
            var objXMLHttp =  new XmlHttp();
                   
            function GetReadyState( ){
				return this.objXmlHttp.readyState;
            }
 
            function GetResponseText( ){
                return this.objXmlHttp.responseText;
            }

			function GetResponse(){
				if (objXMLHttp!=null && objXMLHttp.GetReadyState()==4) {
				var objDivIds = new Array();
					if (objXMLHttp.GetResponseText( )!=''){
						var i = 0;
						objDivIds = objXMLHttp.GetResponseText( ).split('||');
						
						for(i=0;i<objDivIds.length;i++) {
							document.getElementById(tmpDivIds[i]).innerHTML = objDivIds[i];
							if ((i>3)&&(i<8)) {
								if (objDivIds[i] != "0") {
									document.getElementById(tmpDivIds[i]).parentNode.style.display="block";
								} else {
									document.getElementById(tmpDivIds[i]).parentNode.style.display="none";
								}
							}
							if (i>7) {
								if (objDivIds[i].length > 0) {
									//child node 5 is question mark image. please change if html is modified
									if (document.getElementById(tmpDivIds[i]).parentNode.childNodes[5]){
									document.getElementById(tmpDivIds[i]).parentNode.childNodes[5].style.display="block";}
								} else {
									//child node 5 is question mark  image. please change if html is modified
									if (document.getElementById(tmpDivIds[i]).parentNode.childNodes[5]){
									document.getElementById(tmpDivIds[i]).parentNode.childNodes[5].style.display="none";
								}
								}
							}
						}
					}
				}		
			}					
 
            // Function performs Get request to absolute url(strUrl)
            // using XmlHttp object (asynchroni)
            // Response returned into objResult element using innerHTML.
            // When state of XmlHttp object is changed - objOnReadyStateChangeFunction called
			
			function GetUrlContent( strUrl, toSend ,objOnReadyStateChangeFunction,filename){
				if (objXMLHttp.HttpMethod == "GET") {
					this.objXmlHttp.open(this.HttpMethod, strUrl, true);
	                this.objXmlHttp.setRequestHeader('Content-Type', 'text/xml; charset=UTF-8');
				} else {
					this.objXmlHttp.open(this.HttpMethod, filename, true);
	                this.objXmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	                this.objXmlHttp.setRequestHeader("Content-length", strUrl.length);
	                this.objXmlHttp.setRequestHeader("Connection", "close");
	            }
				
				if(objOnReadyStateChangeFunction){
					this.objXmlHttp.onreadystatechange=function(){
						objOnReadyStateChangeFunction();
					}
				}
				this.objXmlHttp.send(strUrl);
				status = true;
			}
           
            //This function is called when we get the data back from the server.       
            function UpdateDiv(DivId, Page, filename, method ) {
				objXMLHttp.HttpMethod = method;
				if (FirstGo==false && objXMLHttp.GetReadyState()!=4){
					UpdateDivByTimeOut(DivId, Page, filename, method);
				} else {
					FirstGo = false;
					status = false;
						tmpDivIds = DivId.split(',');
						if( Page !='' ) {
							objXMLHttp.GetUrlContent( Page, null ,GetResponse, filename);							
						}
				}
				return true;
            }			
			
			function UpdateDivByTimeOut(a, b, c, d){
				if (FirstGo == true){
				UpdateDiv(a, b, c, d);
				} else {
					if(objXMLHttp.GetReadyState()!=4 && time<2001){
					//alert(time);
					time++;				
						if (time==2001){ alert("server is not answering, please try later");}
						setTimeout('UpdateDivByTimeOut("'+a+'", "'+b+'")', 100);
					}
					if(objXMLHttp.GetReadyState()==4 && time<2001){
						UpdateDiv(a, b, c, d);
					}
				}
			}
/*portfolio.js*/
var tabObjId = "ecommerce_tab";

function doOnLoad()
{
	var cookieValue = getCookie("tabCookie");
	if (cookieValue != "" || cookieValue != null)
	{
		if (cookieValue == "1")
			toggleTab(document.getElementById("ecommerce_tab"));
		if (cookieValue == "2")
			toggleTab(document.getElementById("website_design_tab"));
		if (cookieValue == "3")
			toggleTab(document.getElementById("ebay_store_tab"));
	}
}


function toggleTab(obj)
{
	tabObjId = obj.id;
	ecommerce = document.getElementById("ecommerce_design_portfolio");
	webDesign = document.getElementById("website_design_portfolio");
	ebayStore = document.getElementById("ebay_store_design");
	
	ecommerceTab = document.getElementById("ecommerce_tab");
	webdesignTab = document.getElementById("website_design_tab");
	ebaystoreTab = document.getElementById("ebay_store_tab");
	
	if (obj.id == "ecommerce_tab")
	{
		ecommerce.style.display = "block"
		webDesign.style.display = "none"
		ebayStore.style.display = "none"
		setCookie("tabCookie", 1)		
	}
	
	if (obj.id == "website_design_tab")
	{
	
		ecommerce.style.display = "none"
		webDesign.style.display = "block"
		ebayStore.style.display = "none"
		setCookie("tabCookie", 2)
	}
	
	if (obj.id == "ebay_store_tab")
	{
		ecommerce.style.display = "none"
		webDesign.style.display = "none"
		ebayStore.style.display = "block"
		setCookie("tabCookie", 3)
	}	
	
	var portfolioTabArray = getElementsByClassName("portfolio_tab_button")

	for (i = 0; i < portfolioTabArray.length; i++)
	{
		if (obj == portfolioTabArray[i])
		{
			portfolioTabArray[i].style.color = "#ffffff";
			portfolioTabArray[i].style.background = "http://www.advansys.com/url(/img.ashx?i=/images/design/buttons/portfolio_hover.png) no-repeat";
		} else {
			portfolioTabArray[i].style.color = "#0f1d31";
			portfolioTabArray[i].style.background = "http://www.advansys.com/url(/img.ashx?i=/images/design/buttons/portfolio.png) no-repeat";
		}
	}
}

function tabHover(obj) 
{
	if (obj.id != tabObjId)
	{
		obj.style.background = "http://www.advansys.com/url(/img.ashx?i=/images/design/buttons/portfolio_hover.png) no-repeat";
		obj.style.color = "#ffffff"
	}
}

function tabOut(obj) 
{
	if (obj.id != tabObjId)
	{		
		obj.style.color = "#0f1d31"
		obj.style.background = "http://www.advansys.com/url(/img.ashx?i=/images/design/buttons/portfolio.png) no-repeat";
	}
}

function getElementsByClassName(classname, node)  
{
    if(!node) node = document.getElementsByTagName("body")[0];
    var a = [];
    var re = new RegExp('\\b' + classname + '\\b');
    var els = node.getElementsByTagName("*");
    for(var i=0,j=els.length; i<j; i++)
        if(re.test(els[i].className))a.push(els[i]);
    return a;
}

function filterportfolios(sel) 
{
	
	var category;
	var divs = [];
	var cats, isCat;
	var Taitl;
	if(sel.options.selectedIndex == 0){
      alert('Please choose an option');
      return false;
   }
   else{
	category = sel.options[sel.selectedIndex].value;
      
      divs = getElementsByClassName("portfoliosngl", document.getElementById("ebay_store_design"));
	  
	  for(var i=0; i<divs.length; i++)
        {
		Taitl = divs[i].title;
		cats = Taitl.split(",");
		isCat = false;
		for(var j=0; j<cats.length; j++)
			{
			if(category==cats[j]) {
				isCat = true;
			}
			}
		if(isCat) {
			divs[i].style.display = "";	
		}
		else {
			divs[i].style.display = "none";	
		}
		}
      
   } 
	return false;
}

function filterportfoliostrio(sel) 
{
	
	var category;
	var divs = [];
	var cats, isCat;
	var Taitl;
	if(sel.options.selectedIndex == 0){
      //alert('Please choose an option');
      //return false;
	  
	  divs = getElementsByClassName("portfoliolisttrio", document.getElementById("portlistpage"));
	  for(var i=0; i<divs.length; i++)
        {
			divs[i].style.display = "";
		}
   }
   else{
	category = sel.options[sel.selectedIndex].value;
      
      divs = getElementsByClassName("portfoliolisttrio", document.getElementById("portlistpage"));
	  
	  for(var i=0; i<divs.length; i++)
        {
		Taitl = divs[i].title;
		cats = Taitl.split(",");
		isCat = false;
		for(var j=0; j<cats.length; j++)
			{
			if(category==cats[j]) {
				isCat = true;
			}
			}
		if(isCat) {
			divs[i].style.display = "";	
		}
		else {
			divs[i].style.display = "none";	
		}
		}
      
   } 
	return false;
}

function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setTime(exdate.getTime()+(15*60*1000));
var c_value=escape(value) + "; expires="+exdate.toUTCString();
document.cookie=c_name + "=" + c_value;
}

function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}
